﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace CRM_Project
{
    public partial class AgentReservations : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString.Count != 0)
                {
                    string param;
                    param = Request.QueryString.GetValues("RequestID")[0].ToString();
                    //delete from new_request where id is 'param'
                    //delete from reservation where request_id is 'param'
                }
            }
        }

        protected void search_button_Click(object sender, EventArgs e)
        {
            LinqDataSource1.WhereParameters.Clear();
            LinqDataSource1.AutoGenerateWhereClause = true;

            if (customer_textbox.Text != "")
                LinqDataSource1.WhereParameters.Add("CustomerName", customer_textbox.Text);
            if (creditcard_textbox.Text != "")
                LinqDataSource1.WhereParameters.Add("CreditCardNumber", creditcard_textbox.Text);
            if (pickupLot_textbox.Text != "")
                LinqDataSource1.WhereParameters.Add("StartLot.Name", pickupLot_textbox.Text);
            if (returnLot_textbox.Text != "")
                LinqDataSource1.WhereParameters.Add("EndLot.Name", returnLot_textbox.Text);
            if (pickupdate_calendar.SelectedDate != DateTime.MinValue)
                LinqDataSource1.WhereParameters.Add("StartTime", TypeCode.DateTime, pickupdate_calendar.SelectedDate.ToString());
            if (returndate_calendar.SelectedDate != DateTime.MinValue)
                LinqDataSource1.WhereParameters.Add("EndTime", TypeCode.DateTime, returndate_calendar.SelectedDate.ToString());

            DataBind();
            GridView1.Visible = true;
        }
    }
}
